package it.polito.connectedcar.trafficlight;

import it.polito.appeal.traci.ControlledLink;

import java.util.List;
import java.util.Map;

/**
 * This Delegate class follows the Delegate pattern and is used to bring
 * information from lower levels to upper levels when something useful is
 * changed
 * 
 * @author Nicola Aresta
 * 
 */
public interface TrafficLightUpdateDelegate {

	/**
	 * Invoked when the current phase duration of the source Traffic Light is
	 * changed
	 * 
	 * @param duration
	 *            expressed in milliseconds
	 */
	public void onCurrentPhaseDurationChange(int duration);

	/**
	 * Invoked when the assumed time before the next phase switch changed. This
	 * can be the case of adaptive Traffic Lights, in which the phase duration
	 * is related to other factors such as the traffic load on a given lane
	 * 
	 * @param remainingTime
	 *            expressed in milliseconds
	 */
	public void onNextPhaseRemainingTimeChange(int remainingTime);

	/**
	 * Invoked when the source traffic Light changed the phase.
	 * 
	 * @param currentPhase
	 *            the index of the phase in the traffic light program
	 */
	public void onPhaseChanged(int currentPhase);

	/**
	 * RYG( red, yellow, green ) representation of the currently active phase.
	 * each character in the RYGstate identifies the color shown on the lane
	 * given by the index of the character in the whole string
	 * 
	 * @param RYGstate
	 *            current state expressed as a sequence of characters
	 */
	public void onRYGStateChange(String RYGstate);

	/**
	 * This is almost never called because the Links managed by a Traffic Light
	 * never changes in time
	 * 
	 * @param controlledLinks
	 *            the set of controlled links
	 */
	public void onControlledLinksChange(Map<Integer, List<ControlledLink>> controlledLinks);

	/**
	 * Invoked when the Program used by the traffic light has been changed
	 * 
	 * @param tlProgram
	 *            the new program currently running on the Traffic Light
	 */
	public void onCurrentProgramChanged(ConnectedTLProgram tlProgram);

	/**
	 * Simple method invoked to inform about a phase switch without any other
	 * further information
	 */
	public void onSwitch();
}
